<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        var RecentCounter = function() {
            this.q = []
        };

        /**
         * @param {number} t
         * @return {number}
         */
        RecentCounter.prototype.ping = function(t) {
            this.q.push(t)
            while ( t - this.q[0]> 3000 ) {
                this.q.shift()
            }
            return this.q.length;
        };

        /**
         * Your RecentCounter object will be instantiated and called as such:
         * var obj = new RecentCounter()
         * var param_1 = obj.ping(t)
         */
        var recentCounter = new RecentCounter();
        console.log(recentCounter.ping(1))
        console.log(recentCounter.ping(100))
        console.log(recentCounter.ping(3001))
        console.log(recentCounter.ping(3002))
    </script>
</body>
</html>